package hibernate;

import org.hibernate.SessionFactory;
import org.hibernate.cfg.AnnotationConfiguration;

import dominio.Cliente;
import dominio.CondicionCompra;
import dominio.CondicionPago;
import dominio.Cotizacion;
import dominio.Factura;
import dominio.Item;
import dominio.ListaPrecios;
import dominio.OrdenCompra;
import dominio.Proveedor;
import dominio.Rodamiento;
 
public class HibernateUtil
{
    private static final SessionFactory sessionFactory;
    static
    {
        try
        {
        	 AnnotationConfiguration config = new AnnotationConfiguration()
        	 										.addAnnotatedClass(Cliente.class)
        	 										.addAnnotatedClass(CondicionCompra.class)
        	 										.addAnnotatedClass(CondicionPago.class)
        	 										.addAnnotatedClass(Cotizacion.class)
        	 										.addAnnotatedClass(Factura.class)
        	 										.addAnnotatedClass(Item.class)
        	 										.addAnnotatedClass(ListaPrecios.class)
        	 										.addAnnotatedClass(OrdenCompra.class)
        	 										.addAnnotatedClass(Proveedor.class)
        	 										.addAnnotatedClass(Rodamiento.class);   	 
             sessionFactory = config.configure().buildSessionFactory();
        }
        catch (Throwable ex)
        {
            System.err.println("Initial SessionFactory creation failed." + ex);
            throw new ExceptionInInitializerError(ex);
        }
    }
 
    public static SessionFactory getSessionFactory()
    {
        return sessionFactory;
    }
}